
#ifndef _TTG_UTILS_PARAMETERS_BASICPARAMETER_
#define _TTG_UTILS_PARAMETERS_BASICPARAMETER_
#include "Common/Definitions.h"

#include <string>
#include "Common/Math.h"
#include "BasicParameterSet.h"
#include "Runtime.Low/Utils/UtilManagerDll.h"

namespace ttg_internal
{
	namespace utils
	{
		//Basic class for parameters. Wraps raw dll-functions as class.
		class BasicParameter
		{
			private:
				ttg::math::uint64 ID;
				bool is_read_only;
			protected:
				//Creates required parameter in the root set.
				BasicParameter(const char *name, const char *type);
				//Creates required parameter in requred set.
				BasicParameter(const char *name, const char *type, BasicParameterSet *owner);
				//Sets new value for parameter.
				inline void set(const std::string &value)
				{ UtilManagerDll::getRef()->setParameterValue(ID, value.c_str()); }
				//Returns current value of parameter.
				std::string get();
				//Returns true, if parameter was modified since last "get()".
				inline bool wasModified()
				{ return UtilManagerDll::getRef()->wasParameterModified(ID); }
				//Locks parameter to avoid its modification.
				inline void lock_hidden()
				{ UtilManagerDll::getRef()->lockParameter(ID); }
				//UnLocks parameter.
				inline void unLock_hidden()
				{ UtilManagerDll::getRef()->unLockParameter(ID); }
				//Releases parameter.
				~BasicParameter()
				{ UtilManagerDll::getRef()->releaseParameter(ID); ID = 0; }
			public:
				//Returns true, if parameter cannot be changed from external utilities.
				inline bool isReadOnly()
				{ return is_read_only; }
				//Sets state of parameter (defines, can parameter be changed from external utilities or not).
				inline void setReadOnly(bool value)
				{ UtilManagerDll::getRef()->setParameterReadOnly(ID, is_read_only = value); }
				//Returns unique ID of this parameter.
				//It can be used as a hash-value.
				inline ttg::math::uint64 getID()
				{ return ID; }
		};
	}
}

#endif
